package com.example.fourtestapp.ui;

import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.TextView;
import android.widget.VideoView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

import com.example.fourtestapp.R;

public class VideoActivity extends AppCompatActivity {
    private TextView videoTitle;
    private VideoView videoView;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_video);
        initView();
        Intent intent = getIntent();
        String title = intent.getStringExtra("title");
        String url = intent.getStringExtra("url");

        videoTitle.setText(title);

        videoView.setVideoPath(url);
        MediaController controller = new MediaController(VideoActivity.this);
        videoView.setMediaController(controller);
        controller.setMediaPlayer(videoView);
    }

    private void initView() {
        videoTitle = findViewById(R.id.video_title);
        videoView = findViewById(R.id.video_view);
    }
}
